package com.zzw.thread.communicate;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

/**
 * @author zzw
 * @see
 * @since 2018/3/27
 */
public class StreamTest {

    public static void main(String[] args) throws InterruptedException, IOException {

        WriteData writeData = new WriteData();
        ReadData readData = new ReadData();

        PipedInputStream inputStream = new PipedInputStream();
        PipedOutputStream outputStream = new PipedOutputStream();

        // inputStream.connect(outputStream);
        outputStream.connect(inputStream);

        ThreadRead threadRead = new ThreadRead(readData, inputStream);
        threadRead.start();

        Thread.sleep(2000);

        ThreadWrite threadWrite = new ThreadWrite(writeData, outputStream);
        threadWrite.start();
    }
}
